<?php

/**
 * Description of webdb
 *
 * @author bit0rez
 */
class webdb extends CI_Model{
	
	public function __construct() {
		parent::__construct();
	}
	
	public function getNewTweets()
	{
		$CI =&get_instance();
		$db = $CI->load->database('webdb', TRUE);
		$query = $db->query('select * from inet..twitter_VGUES where isNew = 1');
		$data = $query->result_array();
		return $data;
	}
	
	public function getAllowedTweets()
	{
		$CI =&get_instance();
		$db = $CI->load->database('webdb', TRUE);
		$query = $db->query('select * from inet..twitter_VGUES where isNew = 0 and toShow = 1');
		$data = $query->result_array();
		return $data;
	}
	
	public function allowTwit($id)
	{
		$CI =&get_instance();
		$db = $CI->load->database('webdb', TRUE);
		$query = $db->query('update inet..twitter_VGUES set isNew = 0, toShow = 1 where id = '.$id);
		return true;
	}
	
	public function disallowTwit($id)
	{
		$CI =&get_instance();
		$db = $CI->load->database('webdb', TRUE);
		$query = $db->query('update inet..twitter_VGUES set isNew = 0, toShow = 0 where id = '.$id);
		return true;
	}
	
	public function notNew()
	{
		$CI =&get_instance();
		$db = $CI->load->database('webdb', TRUE);
		$query = $db->query('update inet..twitter_VGUES set isNew = 0');
		return true;
	}
	
	public function addObj($data)
	{
		$CI =&get_instance();
		$db = $CI->load->database('webdb', TRUE);
		$query = $db->query('insert into Inet.[dbo].[Webinar](ID,Name,is_active) values('.$data['id'].',\''.$data['subj'].'\',1)');
	}
	
	public function endObj($id)
	{
		$CI =&get_instance();
		$db = $CI->load->database('webdb', TRUE);
		$query = $db->query('update Inet.[dbo].[Webinar] set is_active = 0 where ID = '.$id);
	}
	
	public function actObj($id)
	{
		$CI =&get_instance();
		$db = $CI->load->database('webdb', TRUE);
		$query = $db->query('update Inet.[dbo].[Webinar] set is_active = 1 where ID = '.$id);
	}
	
	public function delObj($id)
	{
		$CI =&get_instance();
		$db = $CI->load->database('webdb', TRUE);
		$query = $db->query('delete from Inet.[dbo].[Webinar] where ID = '.$id);
	}
}

?>
